{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Setting graph specifications"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "global pct `\" 0 \"0%\" .25 \"25%\" .5 \"50%\" .75 \"75%\" 1 \"100%\" \"'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Running ado. file\n",
    "``betterbar`` produces bar graphs with grouping of variables, standard error bars, and cross-group comparisons."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "qui do \"https://raw.githubusercontent.com/SaoriIwa/Stata-IE-Visual-Library/master/Library/Bar%20plots/Horizontal%20bar%20plot%20with%20grouping%20of%20variables%2C%20standard%20error%20bars%2C%20and%20cross-group%20comparisons/betterbar.ado\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Uploading data (.dta)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "use \"https://github.com/SaoriIwa/Stata-IE-Visual-Library/raw/master/Library/Bar%20plots/Horizontal%20bar%20plot%20with%20grouping%20of%20variables%2C%20standard%20error%20bars%2C%20and%20cross-group%20comparisons/data.dta\", clear"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. Creating the graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "(30 real changes made)\n",
      "(29 real changes made)\n"
     ]
    }
   ],
   "source": [
    "betterbar ///\n",
    "\t(dr_3 correct_treatment)  ///\n",
    "\t(med_b2_any_antibiotic med_b2_any_steroid med_b2_any_antister med_l_any_2 med_b2_any_schedule_h med_b2_any_schedule_h1 med_b2_any_schedule_x med_l_any_1)   ///\n",
    "\t, over(city) xlab($pct) se bin legend(pos(5) ring(0) c(1) symxsize(small) symysize(small) ) ysize(7) n barlab(upper)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6. Exporting the graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "qui graph export \"figure.png\" , replace"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Stata",
   "language": "stata",
   "name": "stata"
  },
  "language_info": {
   "file_extension": ".do",
   "mimetype": "text/x-stata",
   "name": "stata"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
